package com.jiang.daily.Q1656;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Jiang
 * @version 1.0
 * @date 2025/02/24 13:13
 */
class OrderedStream {
    private String[] stream;
    private int pre;

    public OrderedStream(int n) {
        stream = new String[n + 1];
        pre = 1;
    }

    public List<String> insert(int idKey, String value) {
        stream[idKey] = value;
        List<String> res = new ArrayList<>();
        while (pre < stream.length && stream[pre] != null) {
            res.add(stream[pre]);
            pre++;
        }
        return res;
    }
}

